package _1_PIO.excel.创建;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.WorkbookUtil;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * 创建Sheet
 */
public class _2_NewSheet {

    @Test
    public void _2003(){

    }

    @Test void _2007() throws IOException {

        Workbook workbook = new XSSFWorkbook();

        String singleSceneString = WorkbookUtil.createSafeSheetName("单场景");
        Sheet singleSceneSheet = workbook.createSheet(singleSceneString);

        String mixedScenesString = WorkbookUtil.createSafeSheetName("混合场景");
        Sheet mixedScenesSheet = workbook.createSheet(mixedScenesString);

        try(OutputStream outputStream = new FileOutputStream("workbook.xlsx")){
            workbook.write(outputStream);
        }
    }


}
